package com.sugar.subscribe.course.module.business.controller.app.order.vo;

import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;

import static com.sugar.subscribe.course.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
import static com.sugar.subscribe.course.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;

@Schema(description = "APP - 订单 Response VO")
@Data
public class AppOrderDetailRespVO {

    // ======================================== 订单基本信息 ========================================

    @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1775")
    private Long id;

    @Schema(description = "教练ID", requiredMode = Schema.RequiredMode.REQUIRED)
    private Long coachId;

    @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED)
    private String orderNo;

    // ======================================== 课程信息 ========================================

    @Schema(description = "上课日期", requiredMode = Schema.RequiredMode.REQUIRED)
    @JsonSerialize(using = LocalDateSerializer.class) // 序列化（响应）
    @JsonDeserialize(using = LocalDateDeserializer.class) // 反序列化（请求）
    @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY)
    private LocalDate attendClassDate;

    @Schema(description = "上课地点名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
    private String venueName;

    @Schema(description = "上课地点坐标点", requiredMode = Schema.RequiredMode.REQUIRED, example = "21073")
    private String location;

    @Schema(description = "服务一级分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
    private String servicePName;

    @Schema(description = "服务二级分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
    private String serviceName;

    @Schema(description = "开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @JsonSerialize(using = LocalTimeSerializer.class) // 序列化（响应）
    @JsonDeserialize(using = LocalTimeDeserializer.class) // 反序列化（请求）
    @JsonFormat(pattern = "HH:mm")
    private LocalTime startTime;

    @Schema(description = "教学人数（字典：business_coach_service_people_count）", requiredMode = Schema.RequiredMode.REQUIRED, example = "19")
    private String peopleCount;

    @Schema(description = "教学时间（字典：business_coach_service_time）", requiredMode = Schema.RequiredMode.REQUIRED)
    private String serviceTime;

    @Schema(description = "雪板类型（字典：business_snowboard_type）", example = "1")
    private String snowboardType;

    @Schema(description = "滑行水平（字典：business_gliding_level）")
    private String businessGlidingLevel;

    @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
    private String nickname;

    @Schema(description = "联络手机号", requiredMode = Schema.RequiredMode.REQUIRED)
    private String mobile;

    @Schema(description = "备注", example = "随便")
    private String remark;

    @Schema(description = "是否修改过上课时间：[0否；1是]", example = "0")
    private Boolean updatedAttendClassDate;

    // ======================================== 支付信息 ========================================

    @Schema(description = "实付金额（单位元）")
    private BigDecimal amount;

    @Schema(description = "下单时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @JsonSerialize(using = LocalDateTimeSerializer.class) // 序列化（响应）
    @JsonDeserialize(using = LocalDateTimeDeserializer.class) // 反序列化（请求）
    @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime orderTime;

    @Schema(description = "支付状态（0待支付；1已支付）", example = "1")
    private Boolean paymentStatus;

    @Schema(description = "支付时间")
    @JsonSerialize(using = LocalDateTimeSerializer.class) // 序列化（响应）
    @JsonDeserialize(using = LocalDateTimeDeserializer.class) // 反序列化（请求）
    @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime paymentTime;

    // ======================================== 订单主要信息 ========================================

    @Schema(description = "接单时间")
    @JsonSerialize(using = LocalDateTimeSerializer.class) // 序列化（响应）
    @JsonDeserialize(using = LocalDateTimeDeserializer.class) // 反序列化（请求）
    @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime receivedTime;

    @Schema(description = "取消时间")
    @JsonSerialize(using = LocalDateTimeSerializer.class) // 序列化（响应）
    @JsonDeserialize(using = LocalDateTimeDeserializer.class) // 反序列化（请求）
    @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime cancelTime;

    @Schema(description = "订单状态（0待接单；1已取消；2待上课；3待确认；4已完成）", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Integer status;

    // ======================================== 教练上课信息 ========================================

    @Schema(description = "上课时间")
    @JsonSerialize(using = LocalDateTimeSerializer.class) // 序列化（响应）
    @JsonDeserialize(using = LocalDateTimeDeserializer.class) // 反序列化（请求）
    @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime attendClassTime;

    @Schema(description = "上课图片")
    private List<String> attendClassImages;

    // ======================================== 教练信息 ========================================

    @Schema(description = "教练昵称", example = "随便")
    private String coachNickname;

    @Schema(description = "教练头像", example = "随便")
    private String coachAvatar;

    @Schema(description = "教练手机号", example = "随便")
    private String coachMobile;
}
